import PropTypes from 'prop-types'
import DescriptionList from '@/components/DescriptionList'
import * as G from '@/utils/common'

const { Description } = DescriptionList

// 东风车辆详情
const DFPVInfo = ({ detail }, { dicData , redisData }) => {
  const {
    vin, brandId, seriesId, styleId, colorId, licence,
    dealerId, doptCode, pdsn, tbox, createDate, dealerInDate, availableDate, purchaseDate,
    enrollDate,carSpt,brandName,seriesName,styleName,colorName,dealerName
  } = detail

  return (
    <DescriptionList title='车辆信息' col={3}  style={{ marginBottom: 16 }}>
      <Description term="VIN号">{vin}</Description>
      <Description term="品牌">{G.getDicByKey(dicData, 'optBrand', brandId) ?? brandId}</Description>
      <Description term="车系">{seriesName}</Description>
      <Description term="车型">{styleName}</Description>
      <Description term="颜色">{colorName}</Description>
      <Description term="车牌">{licence}</Description>
      <Description term="经销商">{dealerName}</Description>
      <Description term="发动机号">{doptCode}</Description>
      <Description term="车机号">{pdsn}</Description>
      <Description term="TBOX号">{tbox}</Description>
      <Description term="入库时间">{dealerInDate}</Description>
      <Description term="销售时间">{availableDate}</Description>
      <Description term="激活时间">{enrollDate}</Description>
      <Description term="网联类型">{carSpt&&carSpt==='1'?'手机':'传统'}</Description>
    </DescriptionList>
  )
}
DFPVInfo.contextTypes = {
  dicData: PropTypes.any,
  redisData: PropTypes.object,
}

// 海马车辆详情 兼容从其它页面跳转的详情
const HAIMAInfo = ({ detail }, { dicData ,redisData }) => {
  const {
    vin, brandName, seriesName, styleName, colorName, licence,
    dealerName, doptCode, pdsn, tbox, createDate, purchaseDate,
    enrollDate,brandId,seriesId,styleId,colorId,dealerId,carSpt
  } = detail
  return (
    <DescriptionList title='车辆信息' col={3}  style={{ marginBottom: 16 }}>
      <Description term="VIN号">{vin}</Description>
      <Description term="品牌">{brandName || G.getDicByKey(dicData, 'optBrand', brandId)}</Description>
      <Description term="车系">{seriesName || G.getDataByCode(redisData, 'vehicleSeriesList', seriesId)}</Description>
      <Description term="车型">{styleName || G.getDataByCode(redisData, 'vehicleTypeList', styleId)}</Description>
      <Description term="颜色">{colorName || G.getDicByKey(dicData, 'vehicleColor', colorId)}</Description>
      <Description term="车牌">{licence}</Description>
      <Description term="经销商">{dealerName || G.getDataByCode(redisData, 'dealerList', dealerId)}</Description>
      <Description term="发动机号">{doptCode}</Description>
      <Description term="车机号">{pdsn}</Description>
      <Description term="TBOX号">{tbox}</Description>
      <Description term="入库时间">{createDate}</Description>
      <Description term="销售时间">{purchaseDate}</Description>
      <Description term="激活时间">{enrollDate}</Description>
      <Description term="网联类型">{carSpt&&carSpt==='1'?'手机':'传统'}</Description>
    </DescriptionList>
  )
}
HAIMAInfo.contextTypes = {
  dicData: PropTypes.any,
  redisData: PropTypes.object,
}

// 北汽车辆详情
const BAICInfo = ({ detail }, { dicData , redisData }) => {
  const {
    vin, brandId, seriesId, styleId, colorId, licence,
    dealerId, doptCode, pdsn, tbox, createDate, purchaseDate,
    enrollDate,carSpt
  } = detail
  return (
    <DescriptionList title='车辆信息' col={3}  style={{ marginBottom: 16 }}>
      <Description term="VIN号">{vin}</Description>
      <Description term="品牌">{G.getDicByKey(dicData, 'optBrand', brandId)}</Description>
      <Description term="车系">{G.getDataByCode(redisData, 'vehicleSeriesList', seriesId)}</Description>
      <Description term="车型">{G.getDataByCode(redisData, 'vehicleTypeList', styleId)}</Description>
      <Description term="颜色">{G.getDicByKey(dicData, 'vehicleColor', colorId)}</Description>
      <Description term="车牌">{licence}</Description>
      <Description term="经销商">{G.getDataByCode(redisData, 'dealerList', dealerId)}</Description>
      <Description term="发动机号">{doptCode}</Description>
      <Description term="车机号">{pdsn}</Description>
      <Description term="TBOX号">{tbox}</Description>
      <Description term="入库时间">{createDate}</Description>
      <Description term="销售时间">{purchaseDate}</Description>
      <Description term="激活时间">{enrollDate}</Description>
      <Description term="网联类型">{carSpt&&carSpt==='1'?'手机':'传统'}</Description>
    </DescriptionList>
  )
}
BAICInfo.contextTypes = {
  dicData: PropTypes.any,
  redisData: PropTypes.object,
}

// 五菱车辆详情
const SGMWInfo = ({ detail }, { dicData , redisData }) => {
  const {
    vin, brandId, seriesId, styleId, colorId, licence,
    dealerId, doptCode, pdsn, tbox, createDate, purchaseDate,
    enrollDate,carSpt
  } = detail
  return (
    <DescriptionList title='车辆信息' col={3}  style={{ marginBottom: 16 }}>
      <Description term="VIN号">{vin}</Description>
      <Description term="品牌">{G.getDicByKey(dicData, 'optBrand', brandId)}</Description>
      <Description term="车系">{G.getDataByCode(redisData, 'vehicleSeriesList', seriesId)}</Description>
      <Description term="车型">{G.getDataByCode(redisData, 'vehicleTypeList', styleId)}</Description>
      <Description term="颜色">{G.getDicByKey(dicData, 'vehicleColor', colorId)}</Description>
      <Description term="车牌">{licence}</Description>
      <Description term="经销商">{G.getDataByCode(redisData, 'dealerList', dealerId)}</Description>
      <Description term="发动机号">{doptCode}</Description>
      <Description term="设备号">{tbox}</Description>
      <Description term="入库时间">{createDate}</Description>
      <Description term="销售时间">{purchaseDate}</Description>
      <Description term="激活时间">{enrollDate}</Description>
      <Description term="网联类型">{carSpt&&carSpt==='1'?'手机':'传统'}</Description>
    </DescriptionList>
  )
}
SGMWInfo.contextTypes = {
  dicData: PropTypes.any,
  redisData: PropTypes.object,
}


// 车辆详情 <若要增加别的品牌的详情，参考上面的写法>
const VehicleInfo = ({ detail, brandId }) => {
  console.log("🚀 ~ VehicleInfo ~ brandId:", brandId)
  const infoMap = new Map([
    ['DFPV', <DFPVInfo detail={detail}  />],
    ['HAIMA', <HAIMAInfo detail={detail}  />],
    ['BAIC', <BAICInfo detail={detail}  />],
    ['SGMW', <SGMWInfo detail={detail}  />],
    ['PEUGEOT', <DFPVInfo detail={detail}  />],
    ['BJEV', <BAICInfo detail={detail}  />],
    ['DCAD', <DFPVInfo detail={detail}  />],
    ['SINOMACH', <DFPVInfo detail={detail}  />],
  ])
  return infoMap.get(brandId) ? infoMap.get(brandId) : <DFPVInfo detail={detail} />
}

export default VehicleInfo
